Conversation
.gitignore
Outdated
| .idea/ | ||
| Java.iml No newline at end of file | ||
| Java.iml | ||
| module5/module5.iml No newline at end of file |
There was a problem hiding this comment.
Please use wildcards for .iml files instead of hardcoded values.
module5/src/main/java/Main.java
Outdated
|
|
||
| private static void validateFacultyGroupStudentsSubjectIsEmpty(List<Faculty> facultyList) throws MyException { | ||
| if (facultyList.isEmpty()) { | ||
| throw new EmptyFacultyListException("You haven't faculty in university."); |
There was a problem hiding this comment.
There is no faculties in university instead of You haven't ...
module5/src/main/java/Main.java
Outdated
| } | ||
| for (Faculty faculty : facultyList) { | ||
| if (faculty.getGroups().isEmpty()) { | ||
| throw new EmptyFacultyGroupsException("You haven't group in " + faculty.getFacultyName() + " faculty"); |
module5/src/main/java/Main.java
Outdated
| } | ||
| for (Group group : faculty.getGroups()) { | ||
| if (group.getStudentsList().isEmpty()) { | ||
| throw new EmptyStudentListException("You haven't students in " + group.getGroupName() + " group."); |
module5/src/main/java/Main.java
Outdated
| for (Group group : faculty.getGroups()) { | ||
| for (Student students : group.getStudentsList()) { | ||
| if (students.getSubjects().containsKey(enteredSubject)) { | ||
| sum += students.getSubjects().get(enteredSubject); |
There was a problem hiding this comment.
You call student.getSubjects() two times.
Create variable for this before if block.
module5/src/main/java/Main.java
Outdated
| "group, for " + subjectName + " is - " + average); | ||
| } | ||
|
|
||
| private static void averageGradeForOneSubjectInUniversity(List<Faculty> facultyList, String enteredSubject) { |
| @@ -0,0 +1,4 @@ | |||
| package bean; | |||
|
|
|||
| public abstract class MyException extends Exception { | |||
There was a problem hiding this comment.
Create constructor:
protected MyException(String message) {
super(message);
}
| @@ -0,0 +1,4 @@ | |||
| package bean; | |||
There was a problem hiding this comment.
move all exceptions to separate package
| package bean; | ||
|
|
||
| public class EmptySubjectException extends MyException { | ||
| private final String studentName; |
There was a problem hiding this comment.
No need to use this field.
Just create constructor:
public EmptySubjectException(String message) {
super(message);
}
Here and in other custom messages.
module5/src/main/java/Main.java
Outdated
| /** | ||
| * Validation what this data is not null. | ||
| * | ||
| * @param facultyList all faculty in university. |
module5/src/main/java/Main.java
Outdated
| } | ||
| for (Faculty faculty : facultyList) { | ||
| if (faculty.getGroups().isEmpty()) { | ||
| throw new EmptyFacultyGroupsException("There is no group in " + faculty.getName() + " faculty"); |
There was a problem hiding this comment.
Sorry, There are no groups...
module5/src/main/java/Main.java
Outdated
| } | ||
| for (Group group : faculty.getGroups()) { | ||
| if (group.getStudentList().isEmpty()) { | ||
| throw new EmptyStudentListException("There is no students in " + group.getName() + " group."); |
There was a problem hiding this comment.
Sorry, There are no students...
module5/src/main/java/Main.java
Outdated
| } | ||
| for (Student students : group.getStudentList()) { | ||
| if (students.getSubjects().isEmpty()) { | ||
| throw new EmptySubjectException("There is " + students.getName() + " no subjects"); |
There was a problem hiding this comment.
Sorry, There is a student ... with no subjects
or Student ... has no subjects
| package exceptions; | ||
|
|
||
| public class EmptyStudentListException extends MyException { | ||
|
|
| package exceptions; | ||
|
|
||
| public class EmptyFacultyGroupsException extends MyException { | ||
|
|
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Students{" + |
module5/src/main/java/Main.java
Outdated
| System.out.println(); | ||
| calculateAverageGradeForOneSubjectInUniversity(facultyList, "Math"); | ||
| } catch (MyException e) { | ||
| e.getStackTrace(); |
There was a problem hiding this comment.
Does this catch block log error message?
module5/src/main/java/Main.java
Outdated
| List<Faculty> emptyFacultyList = emptyFacultyList(); | ||
| List<Faculty> facultyWithoutGroup = facultyWithoutGroup(); | ||
| List<Faculty> groupWithoutStudents = groupWithoutStudents(); | ||
| List<Faculty> studentWithoutSubjects = studentWithoutSubjects(); |
There was a problem hiding this comment.
Now please create List of Lists and do in for loop the next:
- validate each list
- calculate each list's average values (all three methods should be called)
No description provided.